package edu.jhu.tcj.purfuit;

import java.io.FileNotFoundException;
import java.io.IOException;

public class CategoryManager {

	private Category[] categories;

	private static CategoryManager instance;
	
	private CategoryManager() {
		try {
			categories = Category.loadCategories();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	public static CategoryManager getInstance(){
		if (instance == null) {
			instance = new CategoryManager();
		}
		return instance;
	}
	
	public Category getCategory(int ID) {
		for (Category category : categories) {
			if (category.getID() == ID) {
				return category;
			}
		}
		return null;
	}

	public Category[] getCategories() {
		return categories;
	}
	
}
